/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.axiom.utility;

import java.util.Iterator;
import java.util.List;

/**
 *
 * @author Shuhail
 */
public class IdGenerator {
    
    public static IdGenerator getInstance() {
        
        return new IdGenerator();
    }
    
    
    
     public String getValue(String varCharValue){
        char FirstLetterChar = varCharValue.charAt(0);
        String FirstLetter = String.valueOf(FirstLetterChar);
        String intLeft = "";
        
        intLeft = this.removeFirstCharater(varCharValue);
        Integer pKey = Integer.parseInt(intLeft);
        pKey++;
        intLeft = (String)pKey.toString();
        intLeft = FirstLetter + intLeft;
        
        return intLeft;
    }
     
     private String removeFirstCharater(String varCharValue) {
        
        return varCharValue.substring(1);
    }
     
     public String getTheLastPK(List<String> list) {
         
         
         
        int greatest=0;
        char prefix=list.get(0).toString().charAt(0);
        String largest_no_string="";
        Iterator it=list.iterator();
        while(it.hasNext()) {
            String pk=this.removeFirstCharater((String)it.next());
           
            int g=Integer.parseInt(pk);
           
            if(g>greatest) {
                greatest=g;
               
                largest_no_string=pk;
               
            }
            
        }
        return prefix+largest_no_string;
    }
    
    
    public static void main(String[] args) {
        System.err.println(new IdGenerator().getValue("C202"));
    }
}
